#include "display.h"

void display_init(void)
{
  drv_oled_init();
  
  //display_draw_circle(32,32,16);
}

void display_draw_circle(uint8_t x,uint8_t y,uint8_t r)
{
  uint8_t color;

  color=0xFF;      
  for(uint8_t i=0;i<4;i++){
    drv_oled_set_color(color,color,color);
    drv_oled_draw_circle(x,y,r+i,1);
    //color=0xFF/((i+1)*3);
    color>>=1;
  }
}

void display_draw_ball(uint8_t x,uint8_t y,uint8_t r)
{
  uint8_t color;

  color=4;      
  for(uint8_t i=1;i<=r;i++){
    drv_oled_set_color(color,color,color);
    drv_oled_draw_circle(x,y,i,1);
    color+=4;
  }
}

void display_draw_pulse(uint8_t offset,uint8_t width)
{
#define PULSE_TOP          32
#define PULSE_BOTTOM       64
#define PULSE_HEIGHT       (PULSE_BOTTOM-PULSE_TOP+1)
  
  drv_oled_set_color(0,0,0);
  display_draw_line(0,PULSE_TOP,128,PULSE_HEIGHT);
  
  drv_oled_set_color(0xFF,0xFF,0xFF);
  
  if(offset>0)
    drv_oled_draw_line(0,PULSE_BOTTOM,offset,1);
  
  if(width>0)
    drv_oled_draw_line(offset,PULSE_TOP,width,1); 
  
  if((offset+width)<128)
    drv_oled_draw_line(offset+width,PULSE_BOTTOM,(128-(offset+width)),1);
  
  drv_oled_set_color(0x8F,0x8F,0x8F);
  
  if(offset>0)
    drv_oled_draw_line(offset,PULSE_TOP,1,PULSE_BOTTOM-PULSE_TOP);
  
  if(width>0)
    drv_oled_draw_line(offset+width,PULSE_TOP,1,PULSE_HEIGHT);
}
